package com.applabs.dnd.core;

import android.util.Log;

import java.util.HashMap;

public class DNDCallSettings {

	private static String TAG="DNDCallSettings";
	/* White list info to disable DND, contains Number (?), Number*/
	private HashMap <String,String> mWhiteList; //Shouldn't it be only number?
	/* DND Setting to be applied*/
	private int mDNDCallRuleType;
	/* DND Call Reject Type*/
	private int mDNDCallRejType;
	/* Disable DND if NoOfCalls exceeds Limit in DND Call Window */
	private int mDNDCallLimit;
	/* DND Call Limit window */
	private int mDNDCallWindow;
	/* only Active when */
	private String mDNDCallRejectMsg;
	/* Enable DND Linked to Calendar Events*/
	//private boolean bLinkCalendar;

	public DNDCallSettings()
	{
		mWhiteList = new HashMap<String, String>();
		mDNDCallRuleType = DNDCallRuleType.DND_DISABLED;
		mDNDCallRejType = DNDCallRejectType.DND_CALL_REJECT_DISABLED;
		mDNDCallLimit = Constant.DND_CALL_LIMIT_DEFAULT; /* 5 times */
		mDNDCallWindow = Constant.DND_CALL_WINDOW_DEFAULT; /* 5 minutes */
		mDNDCallRejectMsg = ""; /* Default there is no message to be sent to the caller */
		//bLinkCalendar = false; /* Link to calendar disabled */
	}
	
	public DNDCallSettings(HashMap<String, String> whiteList,
							int callRuleType, int callRejType,
							int dNDCallLimit, int dNDCallWindow,
							String callRejectMsg)
	{
		mWhiteList = whiteList;
		mDNDCallRuleType = callRuleType;
		mDNDCallRejType = callRejType;
		mDNDCallLimit = dNDCallLimit > 0 ? dNDCallLimit : 
			Constant.DND_CALL_LIMIT_DEFAULT; //If user doesn't specify. Default to 5
		mDNDCallWindow = dNDCallWindow > 0 ? dNDCallWindow :
			Constant.DND_CALL_WINDOW_DEFAULT; //If user doesn't specify. Default to 5
		mDNDCallRejectMsg = callRejectMsg;
		//bLinkCalendar = false; /* Link to calendar disabled */
	}

	public boolean addToWhiteList(String number)
	{
		if ( mWhiteList!=null )
		{
			Log.d(TAG,"Added to Whitelist : " + number);
			mWhiteList.put(number, number);
			return true;
		}
		
		return false;
	}
	
	public boolean removeFromWhitelist(String number)
	{
		if ( mWhiteList != null )
		{
			if ( null != mWhiteList.remove(number) )
			{
				return true;
			}
			else
			{
				Log.d(TAG,"No Matching Record : "+number);
				return false;
			}
		}

		return false;
	}
	
	public HashMap<String, String> getWhiteList()
	{
		return mWhiteList;
	}
	
	public int getDNDCallLimit()
	{
		return mDNDCallLimit;
	}
	
	public int getDNDCallWindow()
	{
		return mDNDCallWindow;
	}
	
	public int getDNDCallRuletype()
	{
		return mDNDCallRuleType;
	}
	
	public int getDNDCallRejType()
	{
		return mDNDCallRejType;
	}
	
	public String getDNDCallRejectMsg()
	{
		return mDNDCallRejectMsg;
	}

	public void setWhiteList(HashMap<String, String> whileList)
	{
		mWhiteList = whileList;
	}
	
	public void setDNDCallLimit(int callLimit)
	{
		mDNDCallLimit = callLimit;
	}
	
	public void setDNDCallWindow(int callWnd)
	{
		mDNDCallWindow = callWnd;
	}
	
	public void setDNDCallRuletype(int ruleType)
	{
		mDNDCallRuleType = ruleType;
	}
	
	public void setDNDCallRejType(int rejType)
	{
		mDNDCallRejType = rejType;
	}
	
	public void setDNDCallRejectMsg(String rejMsg)
	{
		mDNDCallRejectMsg = rejMsg;
	}
}
